package junitTests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;

public class DeleteFilesSeleniumTest extends SeleneseTestCase {
	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:8888/");
		selenium.start();
	}

	@Test
	public void testDeleteAudio() throws Exception {
		selenium.open("/login.jsp");
		selenium.type("id=username", "andy.hoody@gmail.com");
		selenium.type("id=password", "werdna");
		selenium.click("id=login");
		selenium.click("link=Continue");
		selenium.waitForPageToLoad("60000");
		assertEquals("Home | Media Vault", selenium.getTitle());
		selenium.click("//div[@id='list']/table/tbody/tr[16]/td[5]/a");
		selenium.waitForPageToLoad("30000");
		assertEquals("Home | Media Vault", selenium.getTitle());
	}
	
	@Test
	public void testDeleteVideo() throws Exception {
		selenium.open("/login.jsp");
		selenium.type("id=username", "andy.hoody@gmail.com");
		selenium.type("id=password", "werdna");
		selenium.click("id=login");
		selenium.click("link=Continue");
		selenium.waitForPageToLoad("60000");
		assertEquals("Home | Media Vault", selenium.getTitle());
		selenium.click("//div[@id='list']/table/tbody/tr[10]/td[5]/a");
		selenium.waitForPageToLoad("30000");
		assertEquals("Home | Media Vault", selenium.getTitle());
	}
	
	@Test
	public void testDeleteImage() throws Exception {
		selenium.open("/login.jsp");
		selenium.type("id=username", "andy.hoody@gmail.com");
		selenium.type("id=password", "werdna");
		selenium.click("id=login");
		selenium.click("link=Continue");
		selenium.waitForPageToLoad("60000");
		assertEquals("Home | Media Vault", selenium.getTitle());
		selenium.click("//div[@id='list']/table/tbody/tr[5]/td[5]/a");
		selenium.waitForPageToLoad("30000");
		assertEquals("Home | Media Vault", selenium.getTitle());
	}
	
	@Test
	public void testDeleteDocument() throws Exception {
		selenium.open("/login.jsp");
		selenium.type("id=username", "andy.hoody@gmail.com");
		selenium.type("id=password", "werdna");
		selenium.click("id=login");
		selenium.click("link=Continue");
		selenium.waitForPageToLoad("60000");
		assertEquals("Home | Media Vault", selenium.getTitle());
		selenium.click("link=Delete");
		selenium.waitForPageToLoad("30000");
		assertEquals("Home | Media Vault", selenium.getTitle());
	}

	@After
	public void tearDown() throws Exception {
		selenium.stop();
	}
}
